package yf.mall.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import yf.mall.entity.CashApplyEntity;
import yf.mall.service.CashApplyService;
import com.yf.response.R;


/**
 * 提现申请表Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Mon Jul 06 11:27:01 CST 2020
 */
@RestController
@RequestMapping("/cash/apply")
public class CashApplyController {
    @Autowired
    private CashApplyService cashApplyService;

    /**
     * 列表提现申请表
     */
    @RequestMapping("/list")
    @RequiresPermissions("cash:apply:list")
    public R list(@RequestParam Map<String,Object> params) {

        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<CashApplyEntity> cashApplyList = cashApplyService.queryList(params);
        return R.ok(new PageInfo(cashApplyList));
    }

    /**
     * 查看提现申请表
     */
    @SysLog("查看提现申请表")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("cash:apply:info")
    public R info(@PathVariable("id") Long id) {
        CashApplyEntity cashApply = cashApplyService.get(id);

        return R.ok(cashApply);
    }

    /**
     * 保存提现申请表
     */
    @SysLog("保存提现申请表")
    @RequestMapping("/save")
    @RequiresPermissions("cash:apply:save")
    public R save(CashApplyEntity cashApply) {
        cashApplyService.save(cashApply);

        return R.ok(cashApply);
    }

    /**
     * 修改提现申请表
     */
    @SysLog("修改提现申请表")
    @RequestMapping("/update")
    @RequiresPermissions("cash:apply:update")
    public R update(CashApplyEntity cashApply) {
        cashApplyService.updateCashApply(cashApply);
        return R.ok(cashApply);
    }

    /**
     * 删除提现申请表
     */
    @SysLog("删除提现申请表")
    @RequestMapping("/delete")
    @RequiresPermissions("cash:apply:delete")
    public R delete(Long[]ids) {
        cashApplyService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有提现申请表
     */
    @SysLog("所有提现申请表")
    @RequestMapping("/queryAll")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<CashApplyEntity> cashApplyList = cashApplyService.queryList(params);

        return R.ok(cashApplyList);
    }

    /**
    @ModelAttribute
    public SearchParam<CashApplyEntity> searchParam(SearchParam<CashApplyEntity> params, CashApplyEntity cashApply) {
        if (cashApply != null) {
            params.setEntity(cashApply);
        }

        return params;
    }
 **/
    /***********自定义开始***********/
}
